﻿export default function define(Blocks: Blockly.BlockDefinitions) {
  Blocks['import_sprites'] = {
    init: function () {
      this.appendDummyInput()
        .appendField("导入 sprites 精灵模块库");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("导入库");
      this.setHelpUrl("");
    }
  };

  Blocks['sprites'] = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("variable"), "sprites")
        .appendField("是精灵");
      this.appendValueInput('text')
        .setCheck(null);
      this.appendDummyInput()
        .appendField(")");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("初始化");
      this.setHelpUrl("");
    }
  };
  
  Blocks['addx'] = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("variable"), "sprites")
        .appendField("左右移动");
      this.appendValueInput('text')
        .setCheck(null);
      this.appendDummyInput()
        .appendField(")");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("负数反方向移动");
      this.setHelpUrl("");
    }
  };
  
    Blocks['addy'] = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("variable"), "sprites")
        .appendField("上下移动");
      this.appendValueInput('text')
        .setCheck(null);
      this.appendDummyInput()
        .appendField(")");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("负数反方向移动");
      this.setHelpUrl("");
    }
  };
  
  Blocks['fd_bk'] = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("variable"), "sprites")
        .appendField(".")
        .appendField(new Blockly.FieldDropdown([["向前", "fd"], ["后退", "bk"]]), "options")
        .appendField("(")
      this.appendValueInput('text')
        .setCheck(null);
      this.appendDummyInput()
        .appendField(")");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("负数反方向移动");
      this.setHelpUrl("");
    }
  };
  
  Blocks['rt_lt'] = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("variable"), "sprites")
        .appendField(".")
        .appendField(new Blockly.FieldDropdown([["左转", "left"], ["右转", "right"]]), "options")
        .appendField("(")
      this.appendValueInput('text')
        .setCheck(null);
      this.appendDummyInput()
        .appendField(")");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("负数反方向移动");
      this.setHelpUrl("");
    }
  };

Blocks['slide'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("variable"), "sprites")
          .appendField("在(");
      this.appendValueInput("text")
          .setCheck(null);
      this.appendDummyInput()
          .appendField(")秒内滑动到[");
      this.appendValueInput("text1")
          .setCheck(null);
      this.appendDummyInput()
          .appendField("])");
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
   this.setTooltip("滑动");
   this.setHelpUrl("");
    }
  };
  
  Blocks['sprites_random'] = {
    init: function () {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("variable"), "sprites")
          .appendField("移动到随机位置");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("随机位置");
      this.setHelpUrl("");
    }
  };
  
  Blocks['bounce'] = {
    init: function () {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("variable"), "sprites")
          .appendField("碰到边缘反弹");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("边缘反弹");
      this.setHelpUrl("");
    }
  };

  Blocks['rotatemode'] = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("variable"), "sprites")
        .appendField("的旋转模式为(");
      this.appendValueInput('text')
        .setCheck(null);
      this.appendDummyInput()
        .appendField(")");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("旋转模式");
      this.setHelpUrl("");
    }
  };
  
  Blocks['scale'] = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("variable"), "sprites")
        .appendField("缩放(");
      this.appendValueInput('text')
        .setCheck(null);
      this.appendDummyInput()
        .appendField(")");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("缩放");
      this.setHelpUrl("");
    }
  };
  
  Blocks['hide'] = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("variable"), "sprites")
        .appendField("隐藏(");
      this.appendValueInput('text')
        .setCheck(null);
      this.appendDummyInput()
        .appendField(")秒后显示");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("隐藏");
      this.setHelpUrl("");
    }
  };
 
  Blocks['show'] = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("variable"), "sprites")
        .appendField("显示(");
      this.appendValueInput('text')
        .setCheck(null);
      this.appendDummyInput()
        .appendField(")秒后隐藏");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("显示");
      this.setHelpUrl("");
    }
  };

  Blocks['mouse_pos'] = {
    init: function () {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("string"), "string")
          .appendField("为鼠标指针坐标");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("坐标");
      this.setHelpUrl("");
    }
  };
  
  Blocks['draw_grid2'] = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("variable"), "sprites")
        .appendField("画");
      this.appendValueInput('text')
        .setCheck(null);
      this.appendDummyInput()
        .appendField("行");
      this.appendValueInput('text1')
        .setCheck(null);
      this.appendDummyInput()
        .appendField("列宽度为");
      this.appendValueInput('text2')
        .setCheck(null);
      this.appendDummyInput()
        .appendField("高度为");
      this.appendValueInput('text3')
        .setCheck(null);
      this.appendDummyInput()
        .appendField("的格子");                
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("画格子图");
      this.setHelpUrl("");
    }
  };

  Blocks['shape'] = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("variable"), "sprites")
        .appendField("共有(");
      this.appendValueInput('text')
        .setCheck(null);
      this.appendDummyInput()
        .appendField(")个造型");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("造型");
      this.setHelpUrl("");
    }
  };

  Blocks['nextshape'] = {
    init: function () {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("variable"), "sprites")
          .appendField("换下一个造型");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(270);
      this.setTooltip("换造型");
      this.setHelpUrl("");
    }
  };
  

}
